
/*******************************************************************************
 * class that represents the Visualization of Area information associated with a
 * mass.
 * Modified from Eddy's GreyIcon.java
 * Arthor: Ningyi Ma
 * Last revised: 12/06/07
 ******************************************************************************/
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;


public class AreaIcon extends VisIcon {
	AreaIcon(String filename) {
		super(filename);
	}

	AreaIcon(Mass mass) {
		super();
		BufferedImage image = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
		// white background
		for(int x=0; x<getIconWidth(); x++) {
			for(int y=0; y<getIconHeight(); y++) {
				image.setRGB(x, y, Color.black.getRGB());
			}
		}
		
		int width = (int) (mass.Area.normalized_value * getIconWidth());
		int height = (int) (mass.Area.normalized_value * getIconHeight());
		
		if(width < 10){
			width = 10;
		}
		
		if(height < 10){
			height = 10;
		}
		
		int pixel = Util.calcualtePixelVis(mass.Area.importance, mass.Area.certainty);
		
		Graphics2D g2d = image.createGraphics();
		g2d.setPaint(new Color(Util.getR(pixel), Util.getG(pixel), Util.getB(pixel), Util.getA(pixel)));
		g2d.fillRect(0, 0, width, height);
		setImage(image);
	}
	

	//@Override
	public int getIconHeight() {
		return 100;
	}

	//@Override
	public int getIconWidth() {
		return 100;
	}
}
